package com.xidian.zhiancloud.service.user;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.syset.PositionMapper;
import com.xidian.zhiancloud.model.syset.PositionList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PositionService extends ServiceImpl<PositionMapper,PositionList> {

    @Autowired
    PositionMapper positionMapper;

    public List<PositionList> getPositionList(Long companyid){
        return positionMapper.getPositionList(companyid);
    }

    public void addPositionList(Integer pid,String name,Long companyid){
        positionMapper.addPositionList(pid,name,companyid);
    }

    public int updatePostion(String id,Integer status,Integer state){
        return positionMapper.updatePostion(id,status,state);
    }

    public void deletePositionList(String id){
        List<String> list = getList(id);
        positionMapper.deletePositionList(list);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }


}
